﻿<Window x:Class="TciNewsReader_2014_04.Controls.FeedCrud"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:infrastructure="clr-namespace:TciNewsReader_2014_04.Infrastructure"
        xmlns:customControls="clr-namespace:CustomControls;assembly=CustomControls"
        Title="{x:Static infrastructure:Constants.ApplicationTitle}" 
        WindowStartupLocation="CenterScreen" Icon="/TciNewsReader-2014-04;component/Resources/Images/Identity/tyburn-geoOrb.png" 
        ShowInTaskbar="False" Topmost="True" SnapsToDevicePixels="True" ResizeMode="NoResize" WindowStyle="ToolWindow"
        >
    <Window.Resources>

    </Window.Resources>
    <Grid Background="Transparent">
        <DockPanel>
            <DockPanel DockPanel.Dock="Bottom" HorizontalAlignment="Stretch">
                <DockPanel.Resources>
                    <Style TargetType="Button">
                        <Setter Property="Width" Value="100"/>
                    </Style>
                </DockPanel.Resources>
                <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                    <customControls:InterItemGap/>
                    <Button Content="Verify all" CommandParameter="true" Command="{Binding FeedCrudVerifyAllCommand}" ToolTip="Assure all feeds are working"/>
                    <customControls:InterItemGap/>
                </StackPanel>
                <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
                    <Button Content="Save changes" HorizontalAlignment="Right" CommandParameter="true" Command="{Binding FeedCrudDoneCommand}"/>
                    <customControls:InterItemGap/>
                    <Button Content="Cancel" HorizontalAlignment="Right" CommandParameter="false" Command="{Binding FeedCrudDoneCommand}"/>
                    <customControls:InterItemGap/>
                </StackPanel>
            </DockPanel>
            <DockPanel DockPanel.Dock="Bottom" Background="Navy">
                <Grid DockPanel.Dock="Top" HorizontalAlignment="Center" Margin="10">
                    <Grid.Resources>
                        <Style TargetType="TextBlock">
                            <Setter Property="TextWrapping" Value="Wrap"/>
                            <Setter Property="Foreground" Value="Wheat"/>
                        </Style>
                    </Grid.Resources>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="150"/>
                        <ColumnDefinition MaxWidth="400"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Column="0" Grid.Row="0" Text="To add a new feed"/>
                    <TextBlock Grid.Column="1" Grid.Row="0" Text="Click on the blank row and enter the URL.  Then press the 'Enter' key."/>
                    <TextBlock Grid.Column="0" Grid.Row="1" Text="To delete a feed"/>
                    <TextBlock Grid.Column="1" Grid.Row="1" Text="Click on the feed and press the 'delete' key."/>
                    <TextBlock Grid.Column="0" Grid.Row="2" Text="To change a feed URL"/>
                    <TextBlock Grid.Column="1" Grid.Row="2" Text="Click on the feed and edit the URL.  Then press the 'Enter' key."/>
                    <TextBlock Grid.Column="0" Grid.Row="3" Text="To save changes"/>
                    <TextBlock Grid.Column="1" Grid.Row="3" Text="Click the 'Verify all' button to assure all feeds are working, then click the 'Save changes' button."/>
                    <TextBlock Grid.Column="0" Grid.Row="4" Text="Note"/>
                    <TextBlock Grid.Column="1" Grid.Row="4" Text="If there have been changes, all URL's must be verified and validated before the 'Save changes' button is enabled.  If there have been no changes, click the 'cancel' button to return."/>
                </Grid>
            </DockPanel>
            <customControls:TextBlockPanelHeader DockPanel.Dock="Top" Text="CRUD (Create, Update, and Delete) Feed Sources" />
            <DataGrid 
                DockPanel.Dock="Top"
                ItemsSource="{Binding CrudWrappers}" 
                SelectionMode="Single"
                SelectionUnit="FullRow"
                CanUserAddRows="True"
                CanUserDeleteRows="True"
                CanUserSortColumns="True"
                AutoGenerateColumns="False"
                IsSynchronizedWithCurrentItem="True"
                SelectedValue="{Binding CrudWrappersSelectedItem}"
                Background="{StaticResource CustomGradientGreenEmber}"
                >
                <DataGrid.RowStyle>
                    <Style TargetType="DataGridRow">
                        <Setter Property="Background" Value="Transparent" />
                        <Setter Property="Foreground" Value="Wheat"/>
                        <Setter Property="FontWeight" Value="Bold"/>
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" Value="Navy"/>
                                <Setter Property="Foreground" Value="White"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </DataGrid.RowStyle>
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Url" Binding="{Binding Url}" IsReadOnly="False"/>
                    <DataGridTextColumn Header="State" Binding="{Binding State}" IsReadOnly="True"/>
                    <DataGridTextColumn Header="Validation" Binding="{Binding ValidationResult}" IsReadOnly="True"/>
                    <DataGridTextColumn Header="Verification" Binding="{Binding UriVerificationResult}" IsReadOnly="True"/>
                    <DataGridTextColumn Header="Notes" Binding="{Binding VerificationResponseTime}" IsReadOnly="True"/>
                </DataGrid.Columns>
            </DataGrid>
        </DockPanel>
    </Grid>
</Window>
